﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GTA.DC.Common.UC
{
    /// <summary>
    /// 标题栏
    /// </summary>
    [DefaultProperty("Text")]
    public partial class UcTitleBar : UserControl
    {
        #region 属性

        /// <summary>
        /// 获取或设置功能描述
        /// </summary>
        public string Information
        {
            get
            {
                return lblInformation.Text;
            }
            set
            {
                lblInformation.Text = value;
            }
        }

        /// <summary>
        /// 获取或设置Icon图片
        /// </summary>
        public Image IconImage
        {
            get
            {
                return picIcon.Image;
            }
            set
            {
                picIcon.Image = value;
            }
        }

        /// <summary>
        /// 获取或设置背景颜色
        /// </summary>
        public override Color BackColor
        {
            get
            {
                return grpPanel.BackColor;
            }
            set
            {
                grpPanel.BackColor = value;
            }
        }

        /// <summary>
        /// 获取或设置背景图片
        /// </summary>
        public override Image BackgroundImage
        {
            get
            {
                return grpPanel.BackgroundImage;
            }
            set
            {
                grpPanel.BackgroundImage = value;
            }
        }

        #endregion

        #region 构造函数
        public UcTitleBar()
        {
            InitializeComponent();
            this.Dock = DockStyle.Top;
        }
        #endregion

        #region 控件大小改变事件
        private void UcTitleBar_Resize(object sender, EventArgs e)
        {
            int height = this.Height - 28;
            height = height < 16 ? 16 : height;
            picIcon.Width = height;
            picIcon.Height = height;
            lblInformation.Left = picIcon.Left + picIcon.Width + 16;
            lblInformation.Width = this.ClientSize.Width - 75 - 16;
        }
        #endregion
    }
}
